import models.Event;
import models.Person;
import play.Logger;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.test.Fixtures;

@OnApplicationStart
public class Bootstrap extends Job {

    /**
     * Do the first database configuration
     */
    @Override
    public void doJob() {
        // Check if the database is empty
//        Fixtures.deleteDatabase();
        Logger.info("app start");
        if (Person.count() == 0) {
            Logger.info("initialize data");
            Fixtures.loadModels("initial-data.yml");

            Event jinis2010 = Event.find("byNick", "jinis2010").first();
            if (jinis2010 != null) {
                /*
                jinis2010.backgroundStyle =
                "margin: 0 auto;"
                + "padding: 0;"
                + "background-color: #E8E8E8;"
                + "background-image: url('http://www.ucsm.edu.pe/catolica/templates/catolica_release5/images/Page-BgTexture.jpg');"
                + "background-repeat: no-repeat;"
                + "background-attachment: scroll;"
                + "background-position: top left;";
                 */
                jinis2010.backgroundStyle =
                        "position: absolute;"
                                + "background-image: url('http://www.ucsm.edu.pe/catolica/templates/catolica_release5/images/Page-BgGradient.jpg');"
                                + "background-repeat: no-repeat;"
                                + "background-color: #E8E8E8;"
                                + "top:0;"
                                + "width:100%;"
                                + "height: 500px;";

                jinis2010.headerStyle = "background: url('http://www.ucsm.edu.pe/jinis/images/ucsmfondo.jpg') scroll left bottom #EDF2F8; color : #FFFFFF; padding : 45px 2em 6em 20px;";
                jinis2010.navStyle = "background-color: #1c447b;";
                jinis2010.h1Style = "color:#cccccc";
                jinis2010.save();
            }
            Event Takahashi = Event.find("byNick", "Takahashi").first();
            if (Takahashi != null) {
                Takahashi.backgroundStyle = "background: url('http://www2.blogblog.com/scribe/bg.gif') repeat scroll 0 0 #CCCCCC; padding : 10px 0;";
                Takahashi.headerStyle = "background: url('http://www.ccsbso.org/design/8C80AD58-78EE-DAE1-DAA6-8984215B75C9/images/bg_header.jpg') repeat-x scroll left bottom #EDF2F8; color : #FFFFFF; padding : 45px 2em 6em 20px;";
                Takahashi.navStyle = "background-color: #FFFFEE;";
                Takahashi.navStyle = "background-color: #FFFFEE;";
                Takahashi.h1Style = "";
                Takahashi.save();
            }
            Event conadepc2011 = Event.find("byNick", "conadepc2011").first();
            if (conadepc2011 != null) {
                conadepc2011.backgroundStyle = "background: url('http://www2.blogblog.com/scribe/bg.gif') repeat scroll 0 0 #CCCCCC; padding : 10px 0;";
                conadepc2011.headerStyle = "background: url('http://www.ccsbso.org/design/8C80AD58-78EE-DAE1-DAA6-8984215B75C9/images/bg_header.jpg') repeat-x scroll left bottom #EDF2F8; color : #FFFFFF; padding : 45px 2em 6em 20px;";
                conadepc2011.navStyle = "background-color: #FFFFEE;";
                conadepc2011.save();
            }
        }
    }
}
